package com.mango.module.ldap.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mango.module.base.Constant;
import com.mango.module.base.config.SpringContextUtils;
import com.mango.module.ldap.domain.PersonDO;
import com.mango.module.ldap.service.IPersonService;
import com.mango.module.util.QueueUtils;
import com.mango.module.util.R;

@Controller
@RequestMapping("/test")
public class TestController {

	@Autowired
	private IPersonService personService;

	@RequestMapping("")
	@ResponseBody
	R test() {
		PersonDO person = new PersonDO();
		person.setName("管理员");
		person.setSn("admin");
		person.setStatus("1");
		person.setOu("yanfa");
		person.setUserId("admin");
		person.setGivenName("admin");
		person.setLastTime("2020年8月30日 下午09时40分21秒");
		person.setZjhm("320323000000000000");
		person.setRoleId("0");
		person.setRoleName("研发人员");
		person.setUserPassword("{MD5}RhqApRIoIspjSAY5ZdZwDg==");
		personService.addUser(person);
		return R.ok();
	}
	
	@RequestMapping("/push")
	@ResponseBody
	R push() {
		// 发送到命令执行队列
		QueueUtils queueUtils = SpringContextUtils.getBean("queueUtils", QueueUtils.class);
		queueUtils.send(Constant.MQ_QUEUE_KEY, "1111111111111111");
		return R.ok("执行成功");
	}

}
